<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
    <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
    <title>Document</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            background: #ccc;
        }
    </style>
    <script type="text/babel">
        class Clock extends React.Component {
            constructor(...args) {
                super(...args);

                this.state = {
                    h: 0,
                    m: 0,
                    s: 0
                };

                var that = this;

                setInterval(function () {
                    that.tick();

                    var time = new Date();


                    // console.log(time.getHours()+'=='+time.getMinutes()+'=='+time.getSeconds());
                }, 1000);
            }

            componentDidMount() {
                this.tick();
            }

            tick() {
                let time = new Date();
                this.setState({
                    h: time.getHours(),
                    m: time.getMinutes(),
                    s: time.getSeconds()
                });
            }

            render() {
                return <div>
                    <span>{this.state.h}</span>:
                    <span>{this.state.m}</span>:
                    <span>{this.state.s}</span>
                </div>;
            }
        }


        window.onload = function () {
            var oDiv = document.getElementById('root');

            ReactDOM.render(
                <Clock/>,
                oDiv
            );
        }
    </script>
</head>
<body>
<div id="root"></div>
</body>
</html>